/**
 * Project Name:EMSInterfaceTest
 * File Name:PaymentConfig.java
 * Package Name:functions.ems_payment
 * Date:2018年7月26日下午4:40:00
 * Copyright (c) 2018, crpcg@crpcg.com All Rights Reserved.
 *
 */

package functions.ems_payment;
/**
 * ClassName:PaymentConfig <br/>
 * Function: TODO ADD FUNCTION. <br/>
 * Reason:	 TODO ADD REASON. <br/>
 * Date:     2018年7月26日 下午4:40:00 <br/>
 * @author   JiangWu	 
 */

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONObject;

import com.beans.PaymentConfigBean;

import coms.Constants;
import frame.HttpHelper;
import frame.InterTest;

public class PaymentConfig implements InterTest{
	String result;
	List<PaymentConfigBean> paymentConfigBeans;
	
	public PaymentConfig() {
	}
	
	/*
	 * selectUrl="/ems-payment/payment/config/select"
	 */
	public void select() {
		String params = "{\"page\":{\"currentPage\":1,\"pageSize\":10,\"recordCount\":0},\"params\":{\"companyCode\":\"\",\"isBillEnable\":\"\",\"isAutoCreatePaymentPublic\":\"\",\"isAutoCreatePaymentPrivate\":\"\",\"isCapitalPlanEnable\":\"\",\"manualChnName\":\"\"},\"sortDTO\":{\"fieldName\":\"\",\"orderBy\":\"\"}}";
		String url = Constants.SELECT_URL;
		try {
			result = HttpHelper.post(params, url);
			System.out.println("select================"+result);
			JSONObject jsonObject = new JSONObject(result);
			int total = jsonObject.getInt("total");
			if(total > 0) {
				JSONArray jsonArray = jsonObject.getJSONArray("list");
				paymentConfigBeans = new ArrayList<PaymentConfigBean>();
				for(int i = 0;i<jsonArray.length();i++) {
					JSONObject data = jsonArray.getJSONObject(i);
					String companyCode = data.getString("companyCode");
					String companyName = data.getString("companyName");
					Object localCashierList = data.get("localCashierList");
					String isBillEnable = data.getString("isBillEnable");
					String isCapitalPlanEnable = data.getString("isCapitalPlanEnable");
					String isAutoCreatePaymentPublic = data.getString("isAutoCreatePaymentPublic");
					String isAutoCreatePaymentPrivate = data.getString("isAutoCreatePaymentPrivate");
					Object manualEmpIdList = data.get("manualEmpIdList");
					Object manualUserCodeList = data.get("manualUserCodeList");
					Object manualChnNameList = data.get("manualChnNameList");
					Object paymentPermissionConfigRespList = data.get("paymentPermissionConfigRespList");
					PaymentConfigBean paymentConfigBean = new PaymentConfigBean(companyCode,companyName, localCashierList, isBillEnable, isCapitalPlanEnable, isAutoCreatePaymentPublic, isAutoCreatePaymentPrivate, manualEmpIdList, manualUserCodeList, manualChnNameList, paymentPermissionConfigRespList);
					paymentConfigBeans.add(paymentConfigBean);
					 
				}
			}
		} catch (Exception e) {
			
			// TODO Auto-generated catch block
			e.printStackTrace();
			
		}
	}


	/**
	 * TODO 简单描述该方法的实现功能（可选）.
	 * @see frame.InterTest#run(java.util.HashMap)
	 */
	@Override
	public void run(Map<Object, Object> paramMap) {
	  select();
		// TODO Auto-generated method stub
		
	}

  @Override
  public boolean getStatus() {
    // TODO Auto-generated method stub
    return false;
  }

  @Override
  public String getRemark() {
    // TODO Auto-generated method stub
    return null;
  }
}

